﻿using System;

public interface IShape
{
    double GetArea();
}

public class Circle : IShape
{
    private readonly double radius;

    public Circle(double radius)
    {
        this.radius = radius;
    }

    public double GetArea()
    {
        return Math.PI * radius * radius;
    }
}

public class Square : IShape
{
    private readonly double sideLength;

    public Square(double sideLength)
    {
        this.sideLength = sideLength;
    }

    public double GetArea()
    {
        return sideLength * sideLength;
    }
}

public class Rectangle : IShape
{
    private readonly double length;
    private readonly double width;

    public Rectangle(double length, double width)
    {
        this.length = length;
        this.width = width;
    }

    public double GetArea()
    {
        return length * width;
    }
}

public class ShapeFactory
{
    public IShape CreateShape(string shapeType, params double[] dimensions)
    {
        switch (shapeType.ToLower())
        {
            case "circle":
                if (dimensions.Length == 1)
                {
                    double radius = dimensions[0];
                    return new Circle(radius);
                }
                break;
            case "square":
                if (dimensions.Length == 1)
                {
                    double sideLength = dimensions[0];
                    return new Square(sideLength);
                }
                break;
            case "rectangle":
                if (dimensions.Length == 2)
                {
                    double length = dimensions[0];
                    double width = dimensions[1];
                    return new Rectangle(length, width);
                }
                break;
        }

        throw new ArgumentException("Invalid shape type or dimensions.");
    }
}

public static class Program
{
    public static void Main()
    {
        ShapeFactory shapeFactory = new ShapeFactory();
        Random random = new Random();
        double totalArea = 0;

        for (int i = 0; i < 10; i++)
        {
            string[] shapeTypes = { "circle", "square", "rectangle" };
            string randomShapeType = shapeTypes[random.Next(shapeTypes.Length)];

            double[] dimensions;
            switch (randomShapeType)
            {
                case "circle":
                    dimensions = new double[] { random.NextDouble() * 10 };
                    break;
                case "square":
                    dimensions = new double[] { random.NextDouble() * 10 };
                    break;
                case "rectangle":
                    dimensions = new double[] { random.NextDouble() * 10, random.NextDouble() * 10 };
                    break;
                default:
                    dimensions = new double[0];
                    break;
            }

            IShape shape = shapeFactory.CreateShape(randomShapeType, dimensions);
            double area = shape.GetArea();
            totalArea += area;
        }

        Console.WriteLine("Total area of shapes: " + totalArea);
    }
}